package com.itheima.health.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SuppressWarnings("ALL")
/**
 * @Description :用户权限测试
 * @author     :LD
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    PasswordEncoder passwordEncoder;

    @PreAuthorize("hasAuthority('CHECKITEM_ADD')")
    @RequestMapping("add.do")
    public String add(){
        System.out.println("===addUser===");
        return "<h1>添加用户</h1>";
    }

    @GetMapping("get")
    public String demo1(){
        String encode = passwordEncoder.encode("123");
        return encode;
    }
}
